home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / asm / alib11b.zip / CODE1.ZIP / DISPGRAP / FONTS_F.ASM < prev    next >
Assembly Source File  |  1993-02-27  |  6KB  |  444 lines

  1. _TEXT SEGMENT BYTE PUBLIC 'CODE'
  2. ASSUME CS:_TEXT
  3. ; This is the FAR implementation of Fontools in C-callable format.
  4. ; Pointers are 32 bit and the large memory model should be used.
  5. ; For more details, see the manual or the C header file.
  6.  
  7. false equ 0
  8. true equ 1
  9. lines200 equ 0
  10. lines350 equ 1
  11. lines400 equ 2
  12. parama equ [bp+6]
  13.  
  14. vseg dw 0b800h
  15. linesperchar db 13 ; points - 1
  16. vga db false
  17. ega db false
  18. vedone db false
  19.  
  20. fontheader db '@JLSFF',1
  21.  
  22. cmpegafalse proc near
  23. cmp byte ptr vedone,true
  24. je cef
  25. call detega
  26. cef:
  27. cmp byte ptr ega,false
  28. ret
  29. cmpegafalse endp
  30.  
  31. cmpvgafalse proc near
  32. cmp byte ptr vedone,true
  33. je cvf
  34. call detega
  35. cvf:
  36. cmp byte ptr vga,false
  37. ret
  38. cmpvgafalse endp
  39.  
  40. PUBLIC _SEQUENCEFONTS
  41.  
  42. _sequencefonts proc far
  43. call cmpegafalse
  44. je nosequence
  45. push ax
  46. push dx
  47. mov ax,0704h
  48. mov dx,03c4h
  49. out dx,ax
  50. mov dx,03ceh
  51. mov ax,0204h
  52. out dx,ax
  53. mov ax,5
  54. out dx,ax
  55. mov ax,0406h
  56. out dx,ax
  57. mov ax,0402h
  58. mov dx,03c4h
  59. out dx,ax
  60. pop dx
  61. pop ax
  62. nosequence:
  63. ret
  64. _sequencefonts endp
  65.  
  66. PUBLIC _DESEQUENCEFONTS
  67.  
  68. _desequencefonts proc far
  69. call cmpegafalse
  70. je nodesequence
  71. push ax
  72. push dx
  73. mov dx,03c4h
  74. mov ax,0302h
  75. out dx,ax
  76. mov ax,0304h
  77. out dx,ax
  78. mov dx,03ceh
  79. mov ax,4
  80. out dx,ax
  81. mov ax,01005h
  82. out dx,ax
  83. mov ax,0e06h
  84. cmp vseg,0b000h
  85. jne d1
  86. mov ax,0606h
  87. d1:
  88. out dx,ax
  89. pop dx
  90. pop ax
  91. nodesequence:
  92. ret
  93. _desequencefonts endp
  94.  
  95. PUBLIC _SETSCANLINES
  96.  
  97. _setscanlines proc far ; number of scanlines as parameter, al
  98.  ; 0=200 lines  1 = 350 lines  2 = 400 lines
  99. push bp
  100. mov bp,sp
  101. jmp ssl
  102. scnlns db 0
  103. ssl:
  104. push ax
  105. push bx
  106. push cx
  107. mov al,parama
  108. mov scnlns,al
  109. cmp al,2
  110. ja nossl
  111. call cmpvgafalse
  112. je nossl
  113. mov al,scnlns
  114. mov ah,012h
  115. mov bx,030h
  116. int 010h
  117. mov ax,083h   ; set mode with no video memory clearing
  118. cmp vseg,0b000h
  119. jne s1
  120. mov ax,087h
  121. s1:
  122. int 010h
  123. mov cx,0c0dh
  124. mov al,scnlns
  125. cmp al,0
  126. jne s2
  127. mov cx,0708h
  128. s2:
  129. mov ax,0100h
  130. int 010h
  131. nossl:
  132. pop cx
  133. pop bx
  134. pop ax
  135. pop bp
  136. ret
  137. _setscanlines endp
  138.  
  139. setlinesperchar proc near
  140. call cmpegafalse
  141. je noslpc
  142. push ax
  143. push bx
  144. push cx
  145. push dx
  146. mov ax,01100h
  147. mov bh,linesperchar
  148. xor bl,bl
  149. xor cx,cx
  150. xor dx,dx
  151. int 010h
  152. pop dx
  153. pop cx
  154. pop bx
  155. pop ax
  156. noslpc:
  157. ret
  158. setlinesperchar endp
  159.  
  160. comparestrings proc near ; compares DS:SI & ES:DI and increments SI & DI
  161.  ; does for CX bytes sets carry flag
  162. cstr:
  163. repe cmpsb
  164. ret
  165. comparestrings endp
  166.  
  167. PUBLIC _READFONT
  168.  
  169. _readfont proc far ; pass on far pointer
  170. push bp
  171. mov bp,sp
  172. push ds
  173. push es
  174. push si
  175. push di
  176. call cmpegafalse
  177. jne rf1
  178. jmp norf
  179. numberofentries db 0
  180. i dw 0
  181. j dw 0
  182. k dw 0
  183. begchar dw 0
  184. endchar dw 0
  185. rf1:
  186. lds si,parama
  187. mov di,seg fontheader
  188. mov es,di
  189. mov di,offset fontheader
  190. mov cx,7
  191. call comparestrings
  192. je goon1
  193. jmp norf
  194. goon1:
  195. xor ax,ax
  196. lodsb
  197. push ax
  198. call _setscanlines
  199. pop ax
  200. lodsb
  201. mov linesperchar,al
  202. cmp al,16
  203. jb goon2
  204. jmp norf
  205. goon2:
  206. call setlinesperchar
  207. lodsb
  208. mov numberofentries,al
  209. mov i,0
  210. f2:
  211. lodsb
  212. xor ah,ah
  213. mov begchar,ax
  214. lodsb
  215. mov endchar,ax
  216.  
  217. mov ax,begchar
  218. mov j,ax
  219. f1:
  220. call _sequencefonts
  221. mov di,0a000h
  222. mov es,di
  223. mov bx,j
  224. mov di,bx
  225. mov cl,5
  226. shl di,cl
  227. mov cl,linesperchar
  228. inc cl
  229. xor ch,ch
  230. shr cl,1
  231. rep movsw
  232. call _desequencefonts
  233. inc j
  234. mov ax,endchar
  235. cmp j,ax
  236. jbe f1
  237. inc i
  238. mov al,numberofentries
  239. xor ah,ah
  240. cmp i,ax
  241. jbe f2
  242. norf:
  243. pop di
  244. pop si
  245. pop es
  246. pop ds
  247. pop bp
  248. ret
  249. _readfont endp
  250.  
  251. PUBLIC _READSCREEN
  252.  
  253. _readscreen proc far ; 32 bit FAR pointer must be passed on
  254. push bp
  255. mov bp,sp
  256. push ds
  257. push es
  258. push si
  259. push di
  260. jmp rs1
  261. xy db 0 
  262. x1 db 1
  263. y1 db 1
  264. x2 db 80
  265. y2 db 25
  266. rs1:
  267. lds si,parama
  268. lodsb
  269. mov x1,al
  270. lodsb
  271. mov y1,al
  272. lodsb
  273. mov x2,al
  274. lodsb
  275. mov y2,al
  276. mov al,y1
  277. mov xy,al
  278. r1:
  279. mov cl,x2
  280. inc cl
  281. mov ch,x1
  282. sub cl,ch
  283. xor ch,ch
  284. shl cx,1
  285. mov di,vseg
  286. mov es,di
  287. mov al,xy
  288. dec al
  289. mov ah,0
  290. mov bl,80
  291. mul bl
  292. mov bl,x1
  293. dec bl
  294. xor bh,bh
  295. add bx,ax
  296. shl bx,1
  297. mov di,bx
  298. r2:
  299. lodsb
  300. stosb
  301. loop r2
  302. inc xy
  303. mov al,y2
  304. cmp xy,al
  305. jbe r1
  306. pop di
  307. pop si
  308. pop es
  309. pop ds
  310. pop bp
  311. ret 
  312. _readscreen endp
  313.  
  314. EGAGrfx proc near ; index in al , value in ah
  315. push dx
  316. mov dx,03ceh
  317. out dx,al
  318. inc dx
  319. mov al,ah
  320. out dx,al
  321. pop dx
  322. ret
  323. EGAgrfx endp
  324.  
  325. detEGA proc near
  326. mov vedone,true
  327. jmp dega
  328. testmask db 1
  329. BIOSbyte db 0
  330. dega:
  331. xor ax,ax
  332. mov es,ax
  333. mov vseg,0b800h
  334. mov bx,0410h
  335. mov al,es:[bx]
  336. and al,48
  337. cmp al,48
  338. jne deg2
  339. mov vseg,0b000h
  340. deg2:
  341. mov bx,0487h
  342. mov al,es:[bx]
  343. mov biosbyte,al
  344. mov ah,012h
  345. mov bx,0ff10h
  346. int 010h
  347. mov al,biosbyte
  348. and al,060h
  349. mov cl,5
  350. shr al,cl
  351. cmp bl,al
  352. je degcont
  353. cmp bh,0ffh
  354. jne degcont
  355. mov ega,false
  356. jmp degend
  357. degcont:
  358. mov ah,testmask
  359. mov al,8
  360. call EGAGrfx
  361. mov dx,03ceh
  362. mov al,8
  363. out dx,al
  364. mov vga,false
  365. mov dx,03cfh
  366. in al,dx
  367. cmp al,testmask
  368. jne eg1
  369. mov vga,true
  370. eg1:
  371. mov ax,0ff08h
  372. call egagrfx
  373. mov EGA,TRUE
  374. degend:
  375. ret
  376. detega endp
  377.  
  378. PUBLIC _SAVEFONTS
  379.  
  380. _savefonts proc far ; pass on FAR pointer for 8192 bytes,
  381. push bp
  382. mov bp,sp
  383. push ds
  384. push es
  385. push si
  386. push di
  387. les di,parama
  388. call _sequencefonts
  389. mov si,0a000h
  390. mov ds,si
  391. xor si,si
  392. mov cx,4096
  393. rep movsw
  394. call _desequencefonts
  395. pop di
  396. pop si
  397. pop es
  398. pop ds
  399. pop bp
  400. ret
  401. _savefonts endp
  402.  
  403. PUBLIC _RESTOREFONTS
  404.  
  405. _restorefonts proc far ; pass on FAR pointer - 8192 bytes req.
  406. push bp
  407. mov bp,sp
  408. push ds
  409. push es
  410. push si
  411. push di
  412. lds si,parama
  413. call _sequencefonts
  414. mov di,0a000h
  415. mov es,di
  416. xor di,di
  417. mov cx,4096
  418. rep movsw
  419. call _desequencefonts
  420. pop di
  421. pop si
  422. pop es
  423. pop ds
  424. pop bp
  425. ret
  426. _restorefonts endp
  427.  
  428. PUBLIC _RESETFONTS
  429.  
  430. _resetfonts proc far ; no params
  431. push ax
  432. mov ax,083h
  433. int 010h
  434. mov al,2
  435. push ax
  436. call _setscanlines
  437. pop ax
  438. pop ax
  439. ret
  440. _resetfonts endp 
  441.  
  442. _TEXT ENDS
  443. END
  444.